package com.hkctp.mybatis.mapper;

import com.hkctp.mybatis.domain.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

    //根据name查询数据
    @Select("select * from User where name =#{name}")
    public List<User> likeName(String name);

    //保存数据
    @Insert("insert into user(name) values(#{name})")
    @Options(useGeneratedKeys=true,keyProperty="id",keyColumn="id")
    public void save(User user);

    //更新数据
    @Update("update user set name = #{name} where id = #{id}")
    public void updateUser(User user);

    //删除数据
    @Delete("delete from user where id = #{id}")
    public void deleteUser(User user);

    @Select("select password from user where username = #{username}")
    public String getPassword(String username);

    @Select("select role from user where username = #{username}")
    public String getRole(String username);
}
